<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.28.
   家居商家订单控制器($$)*/

!defined('Q_PATH') && exit;

class JiajuorderController extends AController{

	public function filter_(&$arrMap){
		$arrMap['A.jiajuorder_realname']=array('like',"%".Q::G('jiajuorder_realname')."%");
		$arrMap['A.jiajuorder_realspace']=array('egt',intval(Q::G('jiajuorder_realspace')));
		$arrMap['A.jiajuorder_qq']=array('like',"%".Q::G('jiajuorder_qq')."%");
		$arrMap['A.jiajuorder_mobile']=array('like',"%".Q::G('jiajuorder_mobile')."%");
		$arrMap['A.jiajuorder_biddingcode']=array('like',"%".Q::G('jiajuorder_biddingcode')."%");

		// 添加时间
		$this->getTime_('A.create_dateline',$arrMap);

		$nJiajuorderSpaceid=Q::G('jiajuorder_spaceid');
		if($nJiajuorderSpaceid!==null && $nJiajuorderSpaceid!=''){
			$arrMap['A.jiajuorder_spaceid']=$nJiajuorderSpaceid;
		}
		
		$nJiajuorderType=Q::G('jiajuorder_type');
		if($nJiajuorderType!==null && $nJiajuorderType!=''){
			$arrMap['A.jiajuorder_type']=$nJiajuorderType;
		}
	}
	
	public function index($sModel=null,$bDisplay=true){
		parent::index('jiajuorder',false);
		$oJiajucompanyclass=Q::instance('JiajucompanyclassModel');
		$this->assign('arrSpaces',$oJiajucompanyclass->getClass(53));
		$this->display(Admin_Extend::template('jiaju','jiajuorder/index'));
	}

	protected function sqljoin_(){
		return "->join('".Q::C('DB_PREFIX')."jiajucompany AS C','C.jiajucompany_id,C.jiajucompany_fullname,C.jiajucompany_isfvip,C.jiajucompany_domain','A.jiajucompany_id=C.jiajucompany_id')".
			"->joinLeft('".Q::C('DB_PREFIX')."jiajucompanyclass AS B','B.jiajucompanyclass_name AS space_name','A.jiajuorder_spaceid=B.jiajucompanyclass_id')";
	}

	public function edit($sMode=null,$nId=null,$bDidplay=true){
		$nId=intval(Q::G('value','G'));
		parent::edit('jiajuorder',$nId,false);

		Core_Extend::loadCache('jiaju_caseclass');
		$this->assign('arrOrderClasss',$GLOBALS['_cache_']['jiaju_caseclass']);

		$this->display(Admin_Extend::template('jiaju','jiajuorder/add'));
	}

	public function insert($sModel=null,$nId=null){
		$nId=Q::G('value');
		parent::insert('jiajuorder',$nId);
	}

	public function update($sModel=null,$nId=null){
		$nId=Q::G('value');
		parent::update('jiajuorder',$nId);
	}

	public function forbid($sModel=null,$sId=null,$bApp=false){
		$nId=intval(Q::G('value','G'));
		parent::forbid('jiajuorder',$nId,true);
	}

	public function resume($sModel=null,$sId=null,$bApp=false){
		$nId=intval(Q::G('value','G'));
		parent::resume('jiajuorder',$nId,true);
	}

	public function clear_recycle($sModel=null,$sField='status'){
		parent::clear_recycle('jiajuorder',$sField);
	}

	public function foreverdelete_deep($sModel=null,$sId=null){
		$sId=Q::G('value');
		parent::foreverdelete_deep('jiajuorder',$sId);
	}

	public function foreverdelete($sModel=null,$sId=null,$bApp=false){
		$sId=Q::G('value');
		parent::foreverdelete('jiajuorder',$sId,true);
	}

	public function orderStatus($status){
		switch($status){
			case 0:// 客户下单
				return '<span style="color:blue;">等待确认</span>';
				break;
			case 1:// 商家确认
				return '<span style="color:#0DD07F;">商家已确认</span>';
				break;
			case 13:
				return '<span style="color:gray;">订单关闭</span>';
				break;
			case 9:
				return '<span style="color:red;">回收站</span>';
				break;
			default:
				return '未知';
				break;
		}
	} 

}
